package cn.edu.ctbu.lddweb.service.lmpl;

import cn.edu.ctbu.lddweb.mapper.GradeMapper;
import cn.edu.ctbu.lddweb.pojo.Grade;
import cn.edu.ctbu.lddweb.service.GradeService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 年级管理实现层
 */
@Service
public class GradeServicelmpl implements GradeService {

    @Autowired
    private GradeMapper gradeMapper;

    @Override
    public List<Grade> selectList(Grade grade) {
        return gradeMapper.selectList(grade);
    }

    @Override
    public Grade findID(@Param("id") int id) {
        return gradeMapper.findID(id);
    }

    @Override
    public int insertGrade(Grade grade) {
        return gradeMapper.insertGrade(grade);
    }

    @Override
    public Boolean checkSupplierUnique(Grade grade) {
        int id = grade.getId()==0?-1:grade.getId();
        Grade info = gradeMapper.checkGradeUnique(grade);
        if(info!=null&&info.getId()!=id){
            return true;
        }
        return false;
    }

    @Override
    public int updateGrade(Grade grade) {
        return gradeMapper.updateGrade(grade);
    }

    @Override
    public int deleteGrade(String id) {
        return gradeMapper.deleteGrade(id);
    }
}
